package com.ewuyong.concurrence.example.threadPool;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;


@Slf4j
public class ThreadPoolExample1 {

    private static ScheduledExecutorService executorService = Executors.newScheduledThreadPool(5);

    public static void main(String[] args) {

        executorService.scheduleAtFixedRate(new Runnable() {
            @Override
            public void run() {
                log.info("Thread count {}", 111);
            }
        }, 1000, 3000, TimeUnit.MILLISECONDS);
        /*for (int i = 0; i < 10; i++) {
            final int count = i;
            executorService.execute(new Runnable() {
                @Override
                public void run() {
                    log.info("Thread count {}", count);
                }
            });
        }*/
        //executorService.shutdown();
    }

}
